<template>
	<!-- 待付款页面 -->
	<!-- 商城购买 支付页面-此时未生成订单，点击立即支付时生成订单并付款 -->
	<view>
		<view class="card_one">
			<view class="card_content" v-if="preventionFlag == 2">
				<p style="font-size: 32rpx; line-height: 44rpx">
					因疫情防控政策要求，该药品需登记后发货
				</p>
				<p class="gray_font" style="font-size: 28rpx; margin-top: 10rpx">
					平台将保护您的隐私安全，请如实填写以下信息
				</p>
			</view>


		</view>
		<!-- 物流选择 -->
		<view class="card_content" style="width: 84%; display: flex">
			<!-- @click="openPop" -->
			<text style="color: red">*</text>
			<text class="" style="width: 200rpx"> 配送方式 </text>
			<view style="width: 75%;display: flex;justify-content: space-between;">
				<text class="" style="width: 80%; text-align: right">
					<!-- 达达 -->
					{{ logisticsObj[logisticsType] || '达达' }}
				</text>
				<!-- <image style="width: 40rpx; height: 30rpx; margin-top: 10rpx" src="../../../pagesSub/static/images/icon_right_black.png"></image> -->
			</view>
		</view>

		<view class="card_content card_one">
			<view style="display: flex; justify-content: space-between" v-if="logisticsType != 2" @click="addadress()">
				<view style="width: 90%">
					<view class="peopinfoContent">
						<view class="peopinfo">
							<text>{{ provinces[0].name }}</text>
							<text class="phone">{{ provinces[0].phone }}</text>
						</view>
					</view>
					<view class="addressinfo">
						<text>
							<!-- 位置信息 -->
							{{
                                provinces[0].region
                                ? provinces[0].region
                                : ''
                            }}{{ provinces[0].address ? provinces[0].address : '' }}
							<!-- {{
                                        provinces[0].addressDistrict
                                        ? provinces[0].addressDistrict
                                        : ''
                                    }}{{ provinces.address ? provinces.address : '' }} -->
						</text>
					</view>
				</view>
				<view style="padding-top: 15rpx">
					<image style="width: 40rpx; height: 30rpx"
						src="../../../pagesSub/static/images/icon_right_black.png"></image>
				</view>
			</view>

			<view class="personal_info pa_top personalfont">
				<text class="peopinfo">就诊人信息</text>
				<view style="display: flex">
					<text style="font-size: 31rpx">
						{{ orderData.patientName ? orderData.patientName : '' }}
						<text style="padding: 0 5rpx">|</text>
						{{
                            orderData.sex == 1
                            ? '男'
                            : orderData.sex == 2
                                ? '女'
                                : ''
                        }}
						<text style="padding: 0 5rpx">|</text>
						{{ orderData.age ? orderData.age : '' }}岁
					</text>
				</view>
			</view>
		</view>

		<!-- 健康防疫 填写体温 -->
		<!-- <temperature
                        ref="childer"
                        :preventionFlag="preventionFlag"
                        @send="getTemperature"
                        @sendInfo="getpreventionInfo"
                        type="toPayfor"
                        :info="{}"
                    ></temperature> -->
		<view class="card_content" v-if="orderData && orderData.type" style="margin-top: 30rpx">
			<!--      药房-->
			<view class="peopinfoContent" v-if="orderData.type == 5">
				<view style="float: left">
					<image style="
                                            width: 80rpx;
                                            height: 80rpx;
                                            border-radius: 50%;
                                        " :src="orderData.storeLogo"></image>
				</view>
				<view class="peopinfo" style="padding-left: 95rpx">
					<text>{{
                        orderData.doctorName ? orderData.doctorName : ''
                    }}</text>
					<text style="padding-left: 15rpx">
						{{ orderData.storeName ? orderData.storeName : '' }}
					</text>
				</view>
				<view class="addressinfo peopinfo" style="padding-left: 95rpx">
					<!-- v-if="orderData.workTime"  -->
					<text style="font-size: 28rpx; color: #d57667">
						营业时间:{{
                            orderData.workTime ? orderData.workTime : ''
                        }}（营业时间内可以配送）
					</text>
				</view>
				<view class="addressinfo peopinfo" style="padding-left: 95rpx">
					<text style="font-size: 28rpx">
						{{
                            orderData.storeAddress
                            ? orderData.storeAddress
                            : ''
                        }}
					</text>
				</view>
			</view>
			<!--      医生-->
			<view class="peopinfoContent" v-else>
				<view style="float: left">
					<image style="
                                            width: 80rpx;
                                            height: 80rpx;
                                            border-radius: 50%;
                                        " :src="orderData.doctorImg"></image>
				</view>
				<view class="peopinfo" style="padding-left: 95rpx">
					<text>{{
                        orderData.doctorName ? orderData.doctorName : ''
                    }}</text>
					<text style="padding-left: 15rpx">
						{{
                            orderData.hospitalName
                            ? orderData.hospitalName
                            : ''
                        }}
					</text>
				</view>
				<view class="addressinfo peopinfo" style="padding-left: 95rpx">
					<text style="font-size: 28rpx">
						{{ orderData.jobTitle ? orderData.jobTitle : '' }} |
						{{ orderData.deptName ? orderData.deptName : '' }}
					</text>
				</view>
			</view>
		</view>
		<view class="card_content card_one" style="margin-top: 30rpx">
			<!-- 药店信息 -->
			<view class="peopinfoContent">
				<view style="float: left">
					<image style="width: 80rpx; height: 80rpx; border-radius: 50%" :src="orderData.storeLogo"></image>
				</view>
				<view class="peopinfo" style="padding-left: 95rpx">
					<text>{{
                        orderData.doctorName ? orderData.doctorName : ''
                    }}</text>
					<text style="padding-left: 15rpx">
						{{ orderData.storeName ? orderData.storeName : '' }}
					</text>
				</view>
				<view class="addressinfo peopinfo" style="padding-left: 95rpx">
					<!-- v-if="orderData.workTime"  -->
					<text style="font-size: 28rpx; color: #d57667">
						营业时间:{{
                            orderData.workTime ? orderData.workTime : ''
                        }}（营业时间内可以配送）
					</text>
				</view>
				<view class="addressinfo peopinfo" style="padding-left: 95rpx">
					<text style="font-size: 28rpx">
						{{
                            orderData.storeAddress ? orderData.storeAddress : ''
                        }}
					</text>
				</view>
			</view>
		</view>
		<view class="durgName pad30" style="text-align: right; color: red">
			注：仅带有
			<image class="yibaoTips" src="../../../static/images/chs.png"></image>
			<!-- <text class="yibaoTips">医保</text> -->
			标志的药品支持医保支付
		</view>
		<view class="card_content">
			<view class="peopinfo" style="display: flex">
				<image style="width: 45rpx; height: 45rpx" src="../../../pagesSub/static/images/icon_h_chu@2x.png">
				</image>
				<view>{{ type == 2 ? '处方信息' : '订单信息' }}</view>
			</view>
			<view>
				<view style="margin-top: 30rpx">
					<text style="font-size: 32rpx">
						{{
                            orderData.pharmacyName ? orderData.pharmacyName : ''
                        }}
					</text>
				</view>
				<view class="medical_content" v-for="(
                                data, index
                            ) in orderData.wxReserveDrugResponseBodies" :key="index">
					<view class="medical_img">
						<image :src="data.drugImg"></image>
					</view>
					<view class="medical_right">
						<view class="medical_title">
							<view>
								<view class="medicalName">
									<view class="durgName">
										<image class="yibaoTips" v-if="(data.medicalItemCode) && data.medicalFlag == 1
                                            " src="../../../static/images/chs.png"></image>
										<!-- <text class="yibaoTips" v-if="data.medicalItemCode">医保</text> -->
										{{ data.drugName }}
									</view>
								</view>
								<view class="specification gray_font">
									规格：{{
                                        data.drugSpecification
                                        ? data.drugSpecification
                                        : '暂无规格'
                                    }}
								</view>
							</view>
							<view class="medicalName">x{{ data.drugCount || 1 }}</view>
						</view>
						<view class="medical_price">￥{{ data.drugPrice || 0 }}</view>
					</view>
				</view>
			</view>
		</view>

		<view class="card_content">
			<view class="personal_info">
				<text class="specification gray_font">开具发票</text>
				<view class="specification" style="display: flex" @click="toggle('bottom')">
					<view v-if="invoiceval.isBill == 1">
						<text style="font-size: 31rpx">本次不开具发票</text>
					</view>
					<view v-if="invoiceval.isBill == 0 &&
                        invoiceval.billType == 1
                        ">
						<text style="font-size: 31rpx">普通发票-个人</text>
					</view>
					<view v-if="invoiceval.isBill == 0 &&
                        invoiceval.billType == 2
                        ">
						<text style="font-size: 31rpx">普通发票-公司</text>
					</view>
					<image style="width: 40rpx;height: 30rpx;margin-top: 8rpx;"
						src="../../../pagesSub/static/images/icon_right_black.png"></image>
				</view>
			</view>
			<view v-if="invoiceval.isBill == 0 && invoiceval.billType == 1">
				<view class="specification">发票抬头：{{ invoiceval.rise }}</view>
			</view>
			<view v-if="invoiceval.isBill == 0 && invoiceval.billType == 2">
				<view class="specification">发票抬头：{{ invoiceval.unitName }}</view>
				<view class="specification">
					纳税人识别号：{{ invoiceval.taxPayerNo }}
				</view>
			</view>
		</view>
		<view>
			<view style="margin-left: 60rpx">选择支付方式</view>
			<view class="card_content">
				<!-- v-if=" storeInfo.weiFlag != 1 || storeInfo.isMedicalSupport != 1" -->
				<!--  //是否是东营的药店  0-是东营 1：不是 -->
				<!-- isMedicalSupport 是否支持医保支付(0是1否)  weiFlag 是否支持微信支付(0是1否) -->
				<radio-group class="radio-wrap" @change="hosChange">
					<!-- 只有东营的显示医保预约 -->
					<label for="" v-if="isDongyingStore == 1">
						<view v-if="storeInfo.weiFlag ==0" class="personal_info"
							style="padding-bottom: 20rpx;border-bottom: 1px solid #fbf5f5;">
							<view style="display: flex">
								<image style="width: 60rpx; height: 48rpx"
									src="../../../pagesSub/static/images/wxpay.png"></image>
								<view>
									<text class="specification" style="margin-left: 20rpx">
										微信支付<text style="font-size: 24rpx" v-if="isShowCoupon.includes('0')
                                            ">{{ couponPayType.fullkey }}</text>
									</text>
								</view>
							</view>
							<radio value="0" :checked="wxPay == '0'" color="#4ccdbc" style="transform: scale(1)" />
						</view>
						<view v-if="storeInfo.isMedicalSupport == 0">
							<view class="personal_info" style="padding: 20rpx 0;border-bottom: 1px solid #fbf5f5;"
								v-if="storeInfo.isDongyingStore == 1">
								<view style="display: flex">
									<image style="width: 60rpx; height: 44rpx" src="../../../static/images/chs.png">
									</image>
									<view>
										<text class="specification" style="margin-left: 20rpx">医保支付<text
												style="font-size: 24rpx"
												v-if="isShowCoupon.includes('1')">{{ couponPayType.fullkey }}</text>
										</text>
									</view>
								</view>
								<radio value="1" :checked="wxPay == '1'" color="#4ccdbc" style="transform: scale(1)" />
							</view>
						</view>
					</label>

					<view v-if="isDongyingStore == 0">
						<!--  //是否是东营的药店  0-是东营 1：不是 -->
						<!-- 是东营药店 -->
						<view>
							<view class="personal_info" style="
                                    padding: 20rpx 0;
                                    border-bottom: 1px solid #fbf5f5;
                                    margin-bottom:10rpx;
                                ">
								<view style="display: flex">
									<image style="width: 60rpx; height: 44rpx" src="../../../static/images/chs.png">
									</image>
									<view>
										<text class="specification" style="margin-left: 20rpx">
											医保预约
										</text>
									</view>
								</view>
								<radio value="yuyue" :checked="wxPay == 'yuyue'" color="#4ccdbc"
									style="transform: scale(1)" />
							</view>
						</view>
						<view class="personal_info" style="padding-bottom: 20rpx;border-bottom: 1px solid #fbf5f5;">
							<view style="display: flex">
								<image style="width: 60rpx; height: 56rpx"
									src="../../../pagesSub/static/images/zhPay.png"></image>
								<view>
									<text class="specification" style="margin-left: 20rpx">
										农行支付<text style="font-size: 24rpx" v-if="isShowCoupon.includes('nonghang')
                                            ">{{ couponPayType.fullkey }}</text>
									</text>
								</view>
							</view>
							<radio value="nonghang" :checked="wxPay == 'nonghang'" color="#4ccdbc"
								style="transform: scale(1)" />
						</view>
						<view class="" v-if="storeInfo.isMedicalSupport == 0">
							<!-- 东营的市aok不为空且不为''时显示东营医保 -->
							<view v-if="storeInfo.cityAok != null && storeInfo.cityAok.length != 0"
								class="personal_info" style="padding: 20rpx 0;border-bottom: 1px solid #fbf5f5;">
								<view style="display: flex">
									<image style="width: 60rpx; height: 60rpx"
										src="../../../pagesSub/static/images/dyyb1.png"></image>
									<view>
										<text class="specification" style="margin-left: 20rpx">
											东营医保<text v-if="isShowCoupon.includes('市医保')
                                                    " style="font-size: 24rpx">{{ couponPayType.fullkey }}</text>
										</text>
									</view>
								</view>
								<radio value="市医保" :checked="wxPay == '市医保'" color="#4ccdbc"
									style="transform: scale(1)" />
							</view>
							<!-- 东营的省aok不为空且不为''时显示油田医保 -->
							<view v-if="storeInfo.provinceAok!=null && storeInfo.provinceAok.length != 0"
								class="personal_info" style="padding: 20rpx 0;border-bottom: 1px solid #fbf5f5;">
								<view style="display: flex">
									<image style="width: 60rpx; height: 56rpx"
										src="../../../pagesSub/static/images/oil1.png"></image>
									<view>
										<text class="specification" style="margin-left: 20rpx">
											油田医保<text v-if="isShowCoupon.includes('省医保')
                                                    " style="font-size: 24rpx">{{ couponPayType.fullkey }}</text>
										</text>
									</view>
								</view>
								<radio value="省医保" :checked="wxPay == '省医保'" color="#4ccdbc"
									style="transform: scale(1)" />
							</view>
						</view>

						<view v-if="storeInfo.weiFlag ==0" class="personal_info" style="padding: 20rpx 0;border-bottom: 1px solid #fbf5f5;
                                            ">
							<view style="display: flex">
								<image style="width: 60rpx; height: 48rpx"
									src="../../../pagesSub/static/images/wxpay.png"></image>
								<view>
									<text class="specification" style="margin-left: 20rpx">
										微信支付<text v-if="isShowCoupon.includes('0')
                                            " style="font-size: 24rpx">{{ couponPayType.fullkey }}</text>
									</text>
								</view>
							</view>
							<radio value="0" :checked="wxPay == '0'" color="#4ccdbc" style="transform: scale(1)" />
						</view>
					</view>
				</radio-group>
			</view>
		</view>
		<!-- 优惠券 -->
<!-- 		<view v-if="activeList.length > 0 ">
			<view v-for="(activeInfo, index) in activeList" :key="index">
				<checkbox-group class="radio-wrap" @change="useCouponChange">
					<label for="" class="servicecard couponCard" style="display: flex;justify-content: space-between;">
						<view>
							<span class="couponType">{{
                                activeType[activeInfo.activityType] ||
                                '平台券'
                            }}</span>
							<div class="disFlex">
								<span>
									<span class="danwei">￥</span>
									<span class="money">{{
                                        activeInfo.useMoney || 0
                                    }}</span>
								</span>
								<span class="manjian">
									满{{ activeInfo.freeMoney }}减{{
                                        activeInfo.useMoney
                                    }}
								</span>
							</div>
							<view class="haveCount" hover-class="none" hover-stop-propagation="false">
								有效期：
							</view>
							<view class="haveCount" hover-class="none" hover-stop-propagation="false">
								{{ activeInfo.startTime }}-{{
                                    activeInfo.endTime
                                }}
							</view>

							 
					 

						<checkbox :disabled="activeInfo.flag === 2" :value="activeInfo.id"
							:checked="selectId == activeInfo.id" color="#4ccdbc"
							style="transform: scale(1); margin-top: 60rpx" />
					 
					</label>
				</checkbox-group>
			</view>
	 
		</view> -->

		<view class="card_content">
			<view class="personal_info">
				<text class="specification gray_font">商品总金额</text>
				<text class="medicalName"> ￥{{ sum }}</text>
			</view>
			<view class="personal_info">
				<text class="specification gray_font">配送费</text>
				<text class="medicalName">
					￥{{ distributionFees ? distributionFees : 0 }}
					<!-- ￥{{ orderData.deliveryFee ? orderData.deliveryFee : '0' }} -->
				</text>
			</view>
			<view class="personal_info">
				<text class="specification gray_font">实付款</text>
				<text class="real_payment medicalName">
					￥{{ allPrice }}
					<!-- ￥{{ allPrice ? allPrice : orderData.actualPayment }} -->
				</text>
			</view>
			<view class="personal_info" v-if="orderValue == 1">
				<text class="specification gray_font">医保余额</text>
				<text class="medicalName">￥{{ yibaoInfo.ye || '0' }}</text>
			</view>
		</view>
		<view class="customerService">
			<image @click="Service" src="../../../pagesSub/static/images/btn_h_ke@2x.png"></image>
		</view>
		<view class="payment_button" v-if="storeInfo.weiFlag == 0 || storeInfo.isMedicalSupport == 0">
			<view class="combined">
				合计:
				<text class="combined_money">￥{{ allPrice }}</text>
			</view>
			<button :disabled="extraction" class="immediate" @click="getOrderPay">
				立即支付
			</button>
		</view>

		<!-- 立即支付确认框  不退不换 -->
		<uni-popup ref="notChangePop" type="dialog">
			<view class="inputDialog">
				<view class="title">
					由于药品属于特殊商品，一经售出，概不退换
				</view>

				<view class="button-bottom">
					<view class="cancel" @click="closeTem">取消</view>
					<view @click="toOrderPay()" class="green_words">确定</view>
				</view>
			</view>
		</uni-popup>
		<!-- 物流弹窗 -->
		<uni-popup ref="logisticsPopup" type="center">
			<view class="dialogDiangnosis" v-show="expressTypeList.length >= 0">
				<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" @scroll="scroll">
					<radio-group class="block" @change="changeCheckbox">
						<label class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in expressTypeList"
							:key="index">
							<uni-list-item :title="item.name" :border="false">
								<template v-slot:footer>
									<radio :value="String(item.type)" color="#4ccdbc" :checked="index == current" />
								</template>
							</uni-list-item>
						</label>
					</radio-group>
				</scroll-view>

				<view class="btn_style">
					<button class="arc_button width"
						style="background: -webkit-linear-gradient(#77e2a4,#4ccdbc) !important;width: 200rpx;line-height: 60rpx;height: 60rpx;border-radius: 30rpx;"
						type="primary" @click="saveDiagnosis">
						确定
					</button>
				</view>
			</view>
		</uni-popup>

		<!-- 发票弹窗 -->
		<uni-popup ref="popup" background-color="#fff" :mask-click="false">
			<view style="padding: 30rpx">
				<view class="colse_content">
					<image @click="closeinvoice" style="width: 50rpx;height: 50rpx;float: right;"
						src="../../../pagesSub/static/images/icon_close_gray.png"></image>
				</view>
				<view class="personal_info">
					<text class="specification">发票类型</text>
					<text class="specification gray_font">普通发票</text>
				</view>
				<view class="personal_info">
					<text class="specification">开具发票</text>
					<view>
						<switch :checked="invoiceval.isBill == 0" color="#4CCCBF"
							style="margin-top: -8rpx;transform: scale(0.7);" @change="changeInvoice" />
					</view>
				</view>
				<view v-if="invoiceval.isBill == 0">
					<text class="specification">发票抬头</text>
					<view class="invoice">
						<view style="margin-right: 15rpx" :class="invoiceval.billType == 1 ? 'tag' : ''"
							@click="invoiceType(1)" class="bth_green">
							个人
						</view>
						<view :class="invoiceval.billType == 2 ? 'tag' : ''" @click="invoiceType(2)" class="bth_green">
							公司
						</view>
					</view>
					<view class="invoiceInput" v-if="invoiceval.billType == 1">
						<view style="display: flex">
							<view style="
                                                color: #ff5100;
                                                font-size: 40rpx;
                                                margin-right: 5rpx;
                                            ">
								*
							</view>
							<uni-easyinput style="width: 100%" v-model="invoiceval.rise" placeholder="请填写开具发票人的姓名">
							</uni-easyinput>
						</view>
					</view>
					<view class="invoiceInput" v-if="invoiceval.billType == 2">
						<view>
							<view style="display: flex">
								<view style="
                                                    color: #ff5100;
                                                    font-size: 40rpx;
                                                    margin-right: 5rpx;
                                                ">
									*
								</view>
								<uni-easyinput style="width: 100%" v-model="invoiceval.unitName"
									placeholder="请填写单位名称"></uni-easyinput>
							</view>
						</view>
						<view style="margin-top: 20rpx">
							<view style="display: flex">
								<view style="
                                                    color: #ff5100;
                                                    font-size: 40rpx;
                                                    margin-right: 5rpx;
                                                ">
									*
								</view>
								<uni-easyinput type="number" style="width: 100%" v-model="invoiceval.taxPayerNo"
									placeholder="请填写纳税人识别号"></uni-easyinput>
							</view>
						</view>
					</view>
				</view>
				<button @click="saveinvoice" class="btn_invoice" type="default">
					确定
				</button>
			</view>
		</uni-popup>
		<!-- 医保预约提示框   -->
		<uni-popup ref="callPop" type="dialog">
			<view class="inputDialog">
				<view class="title">
					请拨打药店电话，预约送药上门，医保支付。
				</view>

				<view class="button-bottom">
					<view class="cancel" @click="closeCall">取消</view>
					<view @click="call()" class="green_words">拨打</view>
				</view>
			</view>
		</uni-popup>
		<!-- 优惠券提示弹窗 -->
		<uni-popup ref="couponPop">
			<view class="inputDialog">
				<view class="title">
					{{ couponPopTips }}
				</view>
				<view class="button-bottom">
					<view class="cancel" @click="closeCoupon">取消</view>
					<view @click="closeCoupon" class="green_words">确定</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	var app = getApp();
	import {
		orderdetail,
		updatebill,
		deletebill
	} from '@/api/prescribing.js';
	import {
		wechatOrderPay,
		paySuccess,
		yibaoOrderPay,
		yibaoMoney,
		getIsDongyingStore,
		nonghangOrderPay,
		getCouponPayType,
		yibaoOrderPay2
	} from '@/api/consult.js';
	import store from '@/store';

	import {
		addressList
	} from '@/api/prescribing.js';
	import {
		getFreight,


	} from '@/api/order.js';

	import {
		userInfo,
		getUserCouponFlag
	} from '@/api/user.js';
	import temperature from 'pagesSub/components/temperature/temperature.vue';

	export default {
		components: {
			temperature,
		},
		data() {
			return {
				payType: {
					nonghang: '农行支付',
					0: '微信支付',
					1: '医保支付',
					省医保: '油田医保',
					市医保: '东营医保',
				},
				activeInfo: {}, //选中的优惠券信息
				selectId: '', ////选择的优惠券id
				couponPayType: {}, //满减提示及标识
				isShowCoupon: [], //可使用优惠券的支付方式
				radioDisabled: true, //支付按钮是否置灰
				couponPopTips: '使用本券请选择中国农业银行支付', //优惠券提示文案

				isDongyingStore: 1, //0是东营 1：非东营
				logisticsObj: {
					1: '达达',
					2: '到店自提',
				}, //已选物流名称
				logisticsType: '2', //配送类型
				current: 0, //选中的下标
				expressIndex: 0, //快递列表的下标
				expressTypeList: [{
						name: '达达',
						type: '1',
					},
					{
						name: '到店自提',
						type: '2',
					}, {
						name: '快递',
						type: '3',
					},
				], // 快递类型列表
				yibaoInfo: {}, // 医保信息
				temperature: '', //体温
				orderValue: '0', //支付方式 0：微信 1：医保 省医保： 油田医保 市医保：东营医保
				wxPay: '0', // 选中的支付方式 0：微信 1：医保 省医保： 油田医保 市医保：东营医保 nonghagn:农行支付
				extraction: false,
				type: '', // 上个页面传过来的类型  // type ==2 预约购药  type==4 扫码购药  6--开具处方  5--商城
				orderid: '',
				orderData: {},
				// checkstatus: 1,
				provinces: [], //地址信息
				storeInfo: {}, //药店信息
				sum: 0, //商品总金额
				allPrice: 0, // 合计、实付款
				distributionFees: 0, //配送费
				invoiceval: { //发票信息
					isBill: 1,
					billType: 1,
					rise: '',
					unitName: '',

					taxPayerNo: '',
				},
				activeList: [], //优惠券列表
				buttonRect: {},

			};
		},
		onLoad(option) {
			
			
			//添加药店是否显示第三种送达方式
			if (store.state.app.flag) {
				//0不支持 1支持
			
				if (store.state.app.flag === '1') {
					this.logisticsType = 3;
					this.expressTypeList = this.expressTypeList.slice(2, 3);
			
				} else {
			
					this.expressTypeList = this.expressTypeList.slice(0, 2);
				}
			
			} else {
			
				this.expressTypeList = this.expressTypeList.slice(0, 2);
			}
			
			
			// type ==2 预约购药  type==4 扫码购药  6--开具处方
			if (option.item) {
				this.orderid = option.item;
				this.type = option.type;
			}

			
			this.getIsDontying(); // 查询是否是东营药店
			this.orderdetails(); //订单详情
		},
		onShow: function() {
		 
		
			
			if (this.logisticsType == 1) {
				// 重新修改地址
				let pages = getCurrentPages(); //获取所有页面栈实例列表
				let nowPage = pages[pages.length - 1]; //当前页页面实例
				// console.log(nowPage,'重新选的地址')

				this.provinces[0] = nowPage.address; ///重新赋值新选的地址
				let newAddressObj = nowPage.address;
				let obj = {
					longitude: newAddressObj.longitude,
					latitude: newAddressObj.latitude,
					recieveName: newAddressObj.name,
					recievePhone: newAddressObj.phone,
					recieveAddress: newAddressObj.address,
					storeId: store.state.app.storeId, //药店id
				}
				this.allPrice = this.sum
				this.freight(obj); // 查询运费
				if (this.activeList.length > 0) {
					//确定优惠券
					this.saveCouponPopup();

				}
			}
			// 立即支付按钮置灰跳转到导航栏：我的
			if (this.extraction) {
				this.$util.Tips({
					endtime: 500,
					// title: '支付成功',
					// icon: 'success',
				}, {
					tab: 1,
					url: '/pages/my/index',
				});
			}
			//医生信息
			this.getUserInfo();


		},
		methods: {
			//医生信息
			getUserInfo() {
				let serviceUidCache = store.state.app.serviceUid || 0;
				// console.log(serviceUidCache);
				userInfo(serviceUidCache)
					.then((res) => {
						this.storeInfo = res.data; //药店信息 包含是否微信支付
					})
					.catch((err) => {
						console.log(err, err);
					});
			},
			// 查询满减券支付方式
			getCouponPaytype() {
				let activeId = (this.activeList[0].id);
				getCouponPayType(activeId)
					.then((res) => {
						if (res.code == 200) {
							this.couponPayType = res.data;
							this.isShowCoupon = res.data.typeList; // true;
							// console.log(this.isShowCoupon,'9999-----优惠券支付方式');
						}
					})
					.catch((err) => {
						uni.showToast({
							title: err,
							icon: 'none',
							duration: 3000,
						});
					});
			},
			// 获取是否是东营药店
			getIsDontying() {
				getIsDongyingStore(this.orderid)
					.then((res) => {
						// console.log(res,'获取是否是东营药店99999')
						this.isDongyingStore = res.data;
					})
					.catch((err) => {
						this.$util.Tips({
							title: err,
							icon: 'none',
							duration: 3000,
						});
					});
			},
			// 医保预约拨打电话
			call() {
				let listPhone = [],
					that = this;

				this.storeInfo.listPhone.map(item => {
					listPhone.push(item)
				})
				listPhone.push(this.storeInfo.doctorPhone) //店长手机
				uni.showActionSheet({
					title: '联系电话',
					itemList: listPhone, // this.listPhone, // '12345676543',
					popover: {
						top: that.buttonRect.top * 2 + that.buttonRect.height,
						left: that.buttonRect.left + that.buttonRect.width / 2
					},
					success: e => {
						// console.log(e, 'e的数据');
						uni.makePhoneCall({
							phoneNumber: listPhone[e.tapIndex], // this.listPhone,
							success: () => {
								// console.log('拨打电话');
							}
						});
					}
				});
			},
			//取消医保预约电话弹框
			closeCall() {
				this.$refs.callPop.close();
			},
			//取消支付弹框
			closeTem() {
				this.$refs.notChangePop.close();
			},
			// 关闭优惠券提示文案对话框
			closeCoupon() {
				this.selectId = '';
				this.$refs.couponPop.close();
			},
			//查询医保余额
			getYibaoMoney() {
				let storeId = (this.orderData.pharmacyId).toString();
				// 医保支付之前需要实名认证，
				yibaoMoney(storeId)
					.then((res) => {
						this.yibaoInfo = res.data;
						// 判断余额够不够 不够的话不让医保支付
						if (this.yibaoInfo.ye < this.orderData.actualPayment) {
							return uni.showToast({
								title: '医保余额不足，请更换支付方式',
								icon: 'none',
								duration: 3000,
							});
						}
					})
					.catch((err) => {
						this.yibaoInfo.ye = 0;
						this.$util.Tips({
							title: err,
							duration: 3000,
						});
					});
			},
			// // 支付方式切换
			hosChange(val) {
				this.orderValue = val.target.value;
				// console.log(val, this.isShowCoupon, this.selectId, this.orderValue, 'vallllll-----')
				this.wxPay = val.target.value;
				let allPrice = this.$util.$h.Add(this.sum, 0);
				let storeId = store.state.app.storeId; // this.orderData.pharmacyId;  //药店id
				// 返回的支付方式和选中的相同的话 就选中 否则不选中
				// !this.isShowCoupon.includes(this.orderValue)
				if (this.isShowCoupon.includes(this.orderValue)) {
					// 选中优惠券-结算逻辑
					this.selectedCoupon();
				} else {
					// 不选中优惠券
					// this.activeInfo.id = ''   //用于回显是否选中优惠券和支付时传给接口uuid值的字段
					this.selectId = ''; //是否可选优惠券标识
					// 结算金额
					this.saveCouponPopup()
				}
				// console.log(allPrice, this.sum,'切换支付方式的价格')

				// 如果是东营药店 orderValue = "省医保"“市医保” 不需要查询医保余额
				// orderValue==1 济南医保支付
				if (this.orderValue == 1) {
					// 医保支付之前需要实名认证，
					yibaoMoney(storeId)
						.then((res) => {
							this.yibaoInfo = res.data;
							// 判断余额够不够 不够的话不让医保支付
							if (this.yibaoInfo.ye < this.orderData.actualPayment) {
								return uni.showToast({
									title: '医保余额不足，请更换支付方式',
									icon: 'none',
									duration: 3000,
								});
							}
						})
						.catch((err) => {
							this.yibaoInfo.ye = 0;
							this.$util.Tips({
								title: err,
								duration: 3000,
							});
						});
				}

				// 非医保预约的获取优惠券
				if (this.wxPay != 'yuyue') {
					this.saveCouponPopup();
				}
			},
			// 选中优惠券
			selectedCoupon() {
				let allPrice = this.$util.$h.Add(this.sum, 0);
				// console.log(allPrice, this.sum, this.activeList,'kkkkkkk-----选中优惠券')
				this.activeList.map((item) => {
					if (allPrice >= item.freeMoney && item.flag == 1) {
						// console.log('选中优惠券信息--',item,)
						item.flag = 1; //1 能用 2：不能用
						this.selectId = item.id;
						this.activeInfo.id = item.id
					} else {
						item.flag = 2;
					}
					// console.log(allPrice,this.sum, this.selectId,'选中后优惠券信息总价和单价')
					this.saveCouponPopup();
				});
			},
			// 发票 个人/公司
			invoiceType(type) {
				// this.orderData.billType = type;
				this.checkstatus = type;
				this.invoiceval.billType = type;
				if ((type = 2)) {
					this.invoiceval.rise = '';
				}
				if ((type = 1)) {
					this.invoiceval.unitName = '';
					this.invoiceval.taxPayerNo = '';
				}

				console.log(this.invoiceval, '发票信息')

			},
			// //发票修改
			saveinvoice() {
				let _this = this;
				// console.log('修改时发票信息', this.invoiceval)
				if (
					_this.invoiceval.billType == '' ||
					_this.invoiceval.billType == null
				) {
					uni.showToast({
						title: '请选择发票类型',
						icon: 'none',
						duration: 3000,
					});
					return;
				}
				if (_this.invoiceval.billType == 1) {
					_this.invoiceval.unitName == '';
					_this.invoiceval.taxPayerNo == '';
					if (
						_this.invoiceval.rise == '' ||
						_this.invoiceval.rise == null
					) {
						uni.showToast({
							title: '请填写发票抬头',
							icon: 'none',
							duration: 3000,
						});
						return;
					}
				}
				if (_this.invoiceval.billType == 2) {
					_this.invoiceval.rise == '';
					if (
						_this.invoiceval.unitName == '' ||
						_this.invoiceval.unitName == null ||
						_this.invoiceval.taxPayerNo == '' ||
						_this.invoiceval.taxPayerNo == null
					) {
						uni.showToast({
							title: '请填写发票信息',
							icon: 'none',
							duration: 3000,
						});
						return;
					}
				}

				updatebill({
						id: _this.orderid,
						billType: _this.invoiceval.billType,
						rise: _this.invoiceval.rise,
						unitName: _this.invoiceval.unitName,
						taxPayerNo: _this.invoiceval.taxPayerNo,
					})
					.then((res) => {
						if (res.code == 200) {
							uni.showToast({
								title: '修改成功',
								duration: 3000,
							});
							this.$refs.popup.close();
							this.orderdetails();
						}
					})
					.catch((err) => {
						console.log('错误#', err);
						this.$util.Tips({
							title: err,
						});
					});
				// console.log("&&&&发票信息",JSON.stringify(_this.orderData))
			},

			// 开具发票按钮
			changeInvoice(e) {
				let _this = this;
				if (e.target.value) {
					// 开发票
					_this.invoiceval.isBill = 0;
					// 默认选中个人 --1
					this.invoiceType()
					// this.invoiceval.type = 1 //发票类型

				} else {
					// 不开发票，将之前发票信息删掉
					_this.invoiceval.isBill = 1;
					deletebill(_this.orderid)
						.then((res) => {
							if (res.code == 200) {
								uni.showToast({
									title: '修改成功',
									duration: 3000,
								});
								this.$refs.popup.close();
								this.orderdetails();
							}
						})
						.catch((err) => {
							console.log('错误#', err);
						});
				}
			},
			// 关闭发票弹窗
			closeinvoice() {
				// this.
				this.$refs.popup.close();
				this.orderdetails();
			},
			toggle(type) {
				this.type = type;
				// open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
				this.$refs.popup.open(type);

			},
			openPop() {
				this.$refs.logisticsPopup.open();
				for (let i = 0; i < this.expressTypeList.length; i++) {
					if (this.expressTypeList[i].type == this.logisticsType) {
						this.current = i; //选中的物流下标
						break;
					}
				}
			},
			// 确定选中的物流
			saveDiagnosis() {
				this.logisticsName = this.expressTypeList[this.current].name; //物流名称
				this.logisticsType = this.expressTypeList[this.current].type; // 物流类型
				this.$refs.logisticsPopup.close();
				if (this.logisticsType == 1) {
					// 达达快递
					this.addressLists();
				} else {
					// 自提
					this.distributionFees = 0;
					this.allPrice = Number(this.$util.$h.Add(
						Number(this.distributionFees),
						Number(this.sum)
					));
				}
				this.saveCouponPopup(); //重新计算金额
			},
			// 选择某个优惠券
			useCouponChange(val) {
				// 返回的可用优惠券的支付方式不包含选中的 将selectId=0 不选中优惠券
				if (!this.isShowCoupon.includes(this.orderValue)) {
					this.selectId = '';
					this.couponPopTips = this.couponPayType.frameKey;
					this.$refs.couponPop.open();
				} else {
					this.selectId = val.target.value[0] || 0;
				}
				this.saveCouponPopup();
			},
			//确定优惠券
			saveCouponPopup() {
				if (this.selectId) {
					this.activeList.map((item) => {
						if (item.id == this.selectId) {
							this.selectCoupon = item.useMoney;
							this.activeInfo = item
						}
					});
					// 商品总金额-优惠金额+配送费
					// this.allPrice = Number(this.$util.$h.Add(
					//     this.$util.$h.Sub(Number(this.sum), Number(this.selectCoupon)),
					//     Number(this.distributionFees)
					// ));
				} else {
					// 不使用优惠券
					this.selectCoupon = 0;
				}
				// 商品总金额-优惠金额+配送费
				this.allPrice = this.$util.$h.Add(
					this.$util.$h.Sub(this.sum, this.selectCoupon),
					this.distributionFees
				);
			},
			// 选择物流
			changeCheckbox(e) {
				for (let i = 0; i < this.expressTypeList.length; i++) {
					if (this.expressTypeList[i].type == e.detail.value) {
						this.current = i; //选中的物流下标
						break;
					}
				}
			},
			// 添加和选取地址方法
			addadress() {
				uni.navigateTo({
					url: `/pagesSub-My/my/addressList`,
				});
			},
			// 查询运费
			freight(obj) {
				let allPrice = this.sum //总价为商品总金额
				let useMoney = this.selectCoupon || this.orderData.couponPrice || 0; //优惠金额
				// console.log(this.sum, allPrice, this.allPrice,'kkk----')
				getFreight(obj)
					.then((res) => {
						// console.log(res, allPrice, '--res运费结果');
						if (res.code == 200) {
							this.distributionFees = this.orderData.deliveryFee = res.data.deliveryFee; //配送费

							this.orderData.cityCode = res.data.cityCode;
							this.orderData.shopNo = res.data.shopNo;

							// 总价格
							this.allPrice = this.$util.$h.Sub(
								this.$util.$h.Add(
									Number(this.orderData.deliveryFee), //配送费
									Number(allPrice) //实付款
								),
								useMoney
							); //|| res.data.actualPayment


						} else {
							this.$util.Tips({
								title: res.msg,
								icon: 'none',
								duration: 3000,
							});
						}
					})
					.catch((err) => {
						this.$util.Tips({
							title: err,
							icon: 'none',
							duration: 3000,
						});
					});
			},
			// 切换快递
			addressLists() {
				addressList()
					.then((res) => {
						console.log("^^^^地址", JSON.stringify(res))
						this.provinces = res.rows.filter(
							(item) => item.defaultFlag == '0'
						);
						// 重新修改地址
						let pages = getCurrentPages(); //获取所有页面栈实例列表
						let nowPage = pages[pages.length - 1]; //当前
						// console.log(nowPage,'重新选的地址')
						if (nowPage.address) {
							this.provinces = [];
							this.provinces.push(nowPage.address);
						}
						if (this.provinces.length > 0) {
							var obj = {
								longitude: this.provinces[0].longitude,
								latitude: this.provinces[0].latitude,
								recieveName: this.provinces[0].name,
								recievePhone: this.provinces[0].phone,
								recieveAddress: this.provinces[0].region,
								storeId: store.state.app.storeId, //药店id
							};

							// console.log(this.allPrice, 'allprice999---');
							// 查询运费
							this.freight(obj)
						} else {
							this.distributionFees = 0; //
							this.cityCode = '';
							this.shopNo = '';
						}
					})
					.catch((err) => {
						console.log('错误#', res);
					});
			},
			Service() {
				uni.navigateTo({
					url: `/pagesSub-My/my/customerService`,
				});
			},
			orderdetails() {
				let _this = this;
				uni.showLoading({
					title: '加载中',
				});
				orderdetail(_this.orderid)
					.then((res) => {
						_this.orderData = res.data;
						// 发票信息
						this.invoiceval = {
							isBill: res.data.isBill,
							taxPayerNo: res.data.taxPayerNo,
							billType: res.data.billType,
							rise: res.data.rise,
							type: res.data.type,
							unitName: res.data.unitName,
							userAddress: res.data.userAddress,
						}
						// 地址信息
						this.provinces[0] = {
							longitude: res.data.longitude,
							latitude: res.data.latitude,
							name: res.data.name,
							phone: res.data.phone,
							address: res.data.address,
							region: res.data.addressDistrict,
							// storeId: store.state.app.storeId, //药店id
						}
						// 优惠券信息
						this.activeInfo = {
							id: res.data.uuid
						}
						this.selectId = res.data.uuid || ''; //详情返回选中的优惠券 

						this.sum = res.data.commodityPrice; //商品总金额
						this.distributionFees = res.data.deliveryFee //订单返回的配送费
						this.wxPay = res.data.payFlag; //默认选中详情中的支付方式 ，其他支付方式置灰
						this.orderValue = res.data.payFlag;
						if (res.data.payFlag == 1) {
							// 医保支付 查询余额
							this.getYibaoMoney();
						}

						this.logisticsType = res.data.deliveryType;
						this.allPrice = res.data.actualPayment //订单返回的总价
						//查询优惠券
						this.useCoupon();
						uni.hideLoading();

					})
					.catch((err) => {
						uni.hideLoading();
						_this.$util.Tips({
							title: err,
						});
						console.log('错误#', err);
					});
			},

			// 取消支付弹窗
			closeTem() {
				this.$refs.notChangePop.close();
			},
			//去支付确认框
			toOrderPay() {
				let _this = this;
				let orderNo = _this.orderid;

				this.$refs.notChangePop.close();
				uni.showLoading({
					title: '加载中',
				});
				_this.extraction = true;
				let params = {};
				if (this.logisticsType == 1) {
					// 快递配送
					params = {
						deliveryType: this.logisticsType, //快递类型
						orderId: orderNo,
						cityCode: _this.orderData.cityCode,
						shopNo: _this.orderData.shopNo,
						deliveryFee: _this.orderData.deliveryFee, // 配送费
						longitude: this.provinces[0].longitude,
						latitude: this.provinces[0].latitude,
						spbillCreateIp: '',
						// 新的地址
						userName: this.provinces[0].name,
						userPhone: this.provinces[0].phone,
						addressDistrict: this.provinces[0].region, //省市区
						address: this.provinces[0].address, //详细地址
						payFlag: this.wxPay, // 支付方式
					};
				} else {
					// 自提
					params = {
						deliveryType: this.logisticsType, //快递类型
						orderId: orderNo,
						deliveryFee: 0,
						spbillCreateIp: '',
						payFlag: this.wxPay, // 支付方式

					};
				}
				// console.log(params, this.orderValue, '9999----支付方式');
				// return
				//   微信支付：0 、 医保支付：1 线下不需要
				if (
					_this.orderValue == 1 ||
					_this.orderValue == '省医保' ||
					_this.orderValue == '市医保'
				) {


					// 医保支付
					this.yibaoPay2(orderNo, params);



				} else if (_this.orderValue == 'nonghang') {
					this.nhPay(orderNo, params);
				} else {
					//   微信支付
					this.getOrderWxPay(orderNo, params);
				}
			},
			// 立即支付
			getOrderPay: function() {
				let _this = this;
				// 如果是医保预约支付弹窗提示
				if (this.wxPay == 'yuyue') {
					return this.$refs.callPop.open();
				}
				if (!this.wxPay) {
					return uni.showToast({
						title: '请选择支付方式',
						icon: 'none',
						duration: 3000,
					});
				}
				// // 提示框 不退换
				this.$refs.notChangePop.open();
			},
			// 农行支付
			// nonghangOrderPay
			nhPay(orderNo, params) {
				params = {
					...params,
					uuid: this.selectId //? this.selectId this.activeInfo.id, //优惠券的uuid
				};

				// console.log(1111,'农行支付入参',params,)
				// return
				// 调用农行支付
				nonghangOrderPay(params)
					.then((res) => {
						this.bankUrl = res.data;
						// console.log(res.data, '要跳转的url');
						let url = encodeURIComponent(JSON.stringify(res.data));
						// console.log(res.data, url, '要跳转的url');

						// 关闭当前页面跳转到支付页面
						uni.redirectTo({
							url: `/pagesSub/homePage/prescribing/webView?url=${url}`, //res.data,
						});
						uni.hideLoading();
					})
					.catch((err) => {
						uni.showToast({
							title: err,
							icon: 'none',
							duration: 3000,
						});
					});
			},
			// 医保支付 v2.0  查询是否是 v1.0还是v2.0
			yibaoPay2(orderNo, params) {
				let that = this;
				params = {
					...params,
					uuid: this.selectId //? this.selectId this.activeInfo.id, //优惠券的uuid
				};
				yibaoOrderPay2({


						orderId: orderNo,
						// storeId: store.state.app.storeId
					})
					.then((res) => {


						uni.hideLoading();
						let data = res.data;


						console.log('----------mallorder2-----------------yibaoPay---------   ')
						//v2.0
						if (data) {



							wx.navigateToMiniProgram({


								appId: 'wxcff29266c94592b5', // 'wxe9ad2ec23f63e83b', //医保小程序的appid
								path: 'pages/proxy',
								extraData: {

									storeSn: data.storeSn,
									orderInfo: data.detail,
									orderPay: params,
								},
								envVersion: 'develop', // develop:开发版，trial体验版，release正式版

								fail(res) {
									//关闭当前页面跳转至订单状态
									if (
										res.errMsg ==
										'navigateToMiniProgram:fail cancel'
									) {

										return that.$util.Tips({
											title: '取消支付',
											icon: 'none',
										});
									}
									//  // errMsg: "navigateToMiniProgram:fail cancel"
								},
							});


							// var item = {





							// 	storeSn: data.storeSn,
							// 	orderInfo: data.detail,
							// 	orderPay: params,

							// };

							// console.log('------1111----------------------------- ' + JSON.stringify(item));
							// app.globalData.threeAppData = item;
							// console.log('------222----------------------------- ' + JSON.stringify(app.globalData
							// 	.threeAppData));


							// uni.navigateTo({
							// 	url: '/pagesSub-pay/proxy',
							// });


						} else {
							//v1.0
							that.yibaoPay(orderNo, params);

						}




					})
					.catch((err) => {

						console.log('-----mallorder2---err------------' + err);
						uni.hideLoading();

						uni.showToast({
							title: err,
							icon: 'none',
							duration: 3000,
						});
					});










			},
			// 医保支付 v1.0
			yibaoPay(orderNo, params) {
				let _this = this;
				// 判断余额够不够 .话不让医保支付
				if (this.yibaoInfo.ye < this.orderData.actualPayment) {
					_this.extraction = false;

					return uni.showToast({
						title: '医保余额不足，请更换支付方式',
						icon: 'none',
						duration: 3000,
					});
				}
				// 非东营的医保支付入参
				if (this.isDongyingStore == 1) {
					params = {
						...params,
						medicalType: this.yibaoInfo.sbjgbh, //医保类型
					};
				} else {
					params = {
						...params,
						medicalType: this.orderValue, //医保类型
					};
				}
				params = {
					...params,
					uuid: this.selectId, // this.activeInfo.id, //优惠券的uuid
				};
				// console.log(2222, '医保支付入参', params,)
				// return



				console.log('---------------------------------    ' + JSON.stringify(params));
				yibaoOrderPay(params)
					.then((res) => {

						_this.extraction = false;
						uni.hideLoading();
						let data = res.data;



						console.log('----------------------appId---------------------mallorder2--------' + data.appId);
						console.log('----------------------appId---------------------mallorder2--------' + data.appId);
						console.log('----------------------appId---------------------mallorder2--------' + data.appId);
						console.log('----------------------appId---------------------mallorder2--------' + data.appId);


						wx.navigateToMiniProgram({
							appId: data.appId, //
							path: 'pages/index/index',
							extraData: {
								tradeno: data.tradeno, //'MPC20200403111232001',
								dyfid: data.dyfid,
								ydbh: data.ydbh,
							},


							envVersion: 'release', // develop:开发版，trial体验版，release正式版

							fail(res) {
								//关闭当前页面跳转至订单状态
								if (
									res.errMsg ==
									'navigateToMiniProgram:fail cancel'
								) {
									_this.extraction = false;
									return _this.$util.Tips({
										title: '取消支付',
										icon: 'none',
									});
								}
								//  // errMsg: "navigateToMiniProgram:fail cancel"
							},
						});
					})
					.catch((err) => {

						console.log('-----mallorder2---err------------' + err);
						uni.hideLoading();
						_this.extraction = false;
						uni.showToast({
							title: err,
							icon: 'none',
							duration: 3000,
						});
					});
			},

			//查询优惠券
			useCoupon() {
				// this.$refs.couponPopup.open('bottom');
				// 查询是否可用优惠券
				let allPrice = this.$util.$h.Add(this.sum, 0);
				let storeId = store.state.app.storeId; //药店id
				let orderId = ''
				if (this.selectId) {
					orderId = this.orderData.orderId //订单id

				}
				getUserCouponFlag(storeId, orderId)
					.then((res) => {
						if (res.code == 200) {
							this.activeList = res.data; // true;
							if (res.data.length > 0) {
								// 查询满减券支付方式
								this.getCouponPaytype();
								this.activeList.map((item) => {
									if (
										allPrice >= item.freeMoney &&
										item.flag == 1
									) {
										item.flag = 1; //1 能用 2：不能用
										// this.selectId = res.data[0].id
										this.couponDisabled = false;
									} else {
										item.flag = 2;
										this.couponDisabled = true;
									}
									return item
								});
							}
						}
					})
					.catch((err) => {
						uni.showToast({
							title: err,
							icon: 'none',
							duration: 3000,
						});
					});
			},


			getOrderWxPay(orderNo, params) {
				let _this = this;
				let goPages;
				let orderId = _this.orderData.orderId;
				if (_this.type == 2) {
					// 我的问诊
					goPages = '/pagesSub-My/my/inquiryList';
				} else {
					// 现场开方或者开具处方 跳转到我的页面
					// goPages = '/pages/my/index';
					goPages = '/pages/my/drugOrderList?status=2';
				}
				params = {
					...params,
					uuid: this.selectId, //this.activeInfo.id, //优惠券的uuid
				};
				// console.log(333, '微信支付入参', params,)
				// return
				wechatOrderPay(params)
					.then((res) => {
						let jsConfig = res.data;
						uni.requestPayment({
							timeStamp: jsConfig.timeStamp,
							nonceStr: jsConfig.nonceStr,
							package: jsConfig.packageValue,
							signType: jsConfig.signType,
							paySign: jsConfig.paySign,
							success: function(ress) {
								uni.hideLoading();
								// 调用接口查询通知接口支付成功，接口修改其订单状态
								// orderData.orderNumber  || orderData.orderId
								uni.showToast({
									title: '支付成功',
									duration: 3000,
								});
								_this.extraction = false;
								if (_this.type == 2) {
									return _this.$util.Tips({
										title: '支付成功',
										icon: 'success',
									}, {
										tab: 5,
										url: goPages,
									});
								} else {
									return _this.$util.Tips({
										title: '支付成功',
										icon: 'success',
									}, {
										tab: 5,
										url: goPages,
									});
								}
							},
							fail: function(e) {
								uni.hideLoading();
								return _this.$util.Tips({
									title: '取消支付',
									icon: 'none',
								}, {
									tab: 5,
									url: '/pages/my/drugOrderList?status=1',
								});
							},
							complete: function(e) {
								uni.hideLoading();
								// console.log('支付结果---', e, orderId)
								//关闭当前页面跳转至订单状态
								if (e.errMsg == 'requestPayment:cancel') {
									return _this.$util.Tips({
										title: '取消支付',
										icon: 'none',
									}, {
										tab: 5,
										url: '/pages/my/drugOrderList?status=1',
									});

								}
							},
						});
					})
					.catch((err) => {
						_this.extraction = false;
						uni.hideLoading();
						return _this.$util.Tips({
							title: err,
						});
					});
			},
		},
	};
</script>

<style lang="scss" scoped>
	@import '@/static/css/style.css';

	// 物流弹窗
	.dialogDiangnosis {
		padding: 30rpx;
		width: 250px;
		/* height: 385px; */
		background-color: #ffffff;
		border-radius: 20rpx;
	}

	.durgName {
		font-size: 30rpx;
		margin-top: 8rpx;
		text-overflow: -o-ellipsis-lastline;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		word-break: break-all;
		-webkit-line-clamp: 2;
		line-clamp: 2;
		-webkit-box-orient: vertical;
	}

	/deep/.uni-easyinput__content-input.data-v-abe12412 {
		font-size: 30rpx;
		text-align: right;
	}

	// /deep/.segmented-control__text.data-v-064e9cd1 {
	//     color:#4cccbf !important
	// }
	// /deep/.segmented-control__item--button.data-v-064e9cd1 {
	//     background-color: pink;
	// }
	.invoiceInput {
		margin-top: 30rpx;
	}

	.tag {
		color: #ffffff !important;
		background-color: #4cccbf !important;
	}

	.bg_image {
		background-image: url(../../../pagesSub/static/images/bg_menzhen@2x.png);
		height: 200rpx;
		background-size: 100% 100%;
		color: #ffffff;
		padding: 30rpx;
	}

	.invoice {
		display: flex;
		margin: 10rpx 0;
	}

	.appointment {
		font-weight: 600;
	}

	.peopinfoContent {
		padding-bottom: 20rpx;
		border-bottom: 1rpx solid #fbfbfb;
	}

	.peopinfo {
		font-size: 32rpx;
	}

	.prompt_font {
		font-size: 29rpx;
		margin-top: 5rpx;
	}

	.card_content {
		background-color: #ffffff;
		padding: 30rpx;
		margin: 30rpx;
		border-radius: 10rpx;
	}

	.card_one {
		// margin-top: -208rpx;
	}

	.phone {
		margin-left: 30rpx;
	}

	.addressinfo {
		color: #3f3f3f;
		font-size: 30rpx;
		margin-top: 5rpx;
	}

	.personal_info {
		display: flex;
		justify-content: space-between;
	}

	.medical_content {
		display: flex;
		margin-top: 30rpx;
		border-bottom: 1rpx solid #fbfbfb;
		padding-bottom: 30rpx;
	}

	.medical_img {
		width: 170rpx;
		height: 120rpx;
	}

	.medical_img image {
		width: 100%;
		height: 100%;
	}

	.medical_right {
		margin-left: 30rpx;
		width: 100%;
	}

	.medical_title {
		display: flex;
		justify-content: space-between;
	}

	.pa_top {
		margin-top: 20rpx;
	}

	.medical_price {
		float: right;
		color: #d57667;
		font-weight: 600;
		font-size: 33rpx;
	}

	.real_payment {
		color: #d57667;
	}

	.btns {
		width: 100%;
		display: flex;
		justify-content: space-between;
		margin-top: 70rpx;
	}

	.bth_green {
		border-top-right-radius: 40rpx;
		border-bottom-right-radius: 40rpx;
		border-top-left-radius: 40rpx;
		border-bottom-left-radius: 40rpx;
		border: 1rpx solid #4cccbf;
		background-color: #ffffff;
		color: #4cccbf;
		height: 50rpx;
		line-height: 50rpx;
		font-size: 24rpx;
		padding: 0 25rpx;
	}

	.add_medical {
		display: flex;
		color: #4cccbf;
		text-align: center;
		font-size: 30rpx;
		margin-top: 40rpx;
		margin-left: 40%;
	}

	.iphoneBottom {
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
		box-sizing: content-box;
	}

	.btn_appointment {
		/*margin-bottom: 40rpx;*/
		background: -webkit-linear-gradient(#77e2a4, #4ccdbc);
		color: #ffffff;
	}

	.btn_invoice {
		color: #ffffff;
		background-color: #4ccdbc;
		font-size: 30rpx;
		margin-top: 60rpx;
		margin-bottom: 30rpx;
	}

	.personalfont {
		font-size: 32rpx;
	}

	.green_font {
		color: #4cccbf;
	}

	.addressName {
		font-size: 30rpx;
		margin-top: 20rpx;
	}

	.medicalName {
		font-size: 31rpx;
	}

	.specification {
		font-size: 30rpx;
		margin-top: 20rpx;
	}

	.icon_greenadd {
		width: 35rpx;
		height: 35rpx;
	}

	.customerService {
		width: 100%;
		height: 200rpx;
		margin-bottom: 150rpx;
	}

	.customerService image {
		width: 120rpx;
		height: 120rpx;
		float: right;
		margin-right: 30rpx;
		margin-top: 20rpx;
	}

	.colse_content::after {
		display: block;
		clear: both;
		content: '';
	}

	/* 支付按钮 */
	.payment_button {
		width: 100%;
		display: flex;
		position: fixed;
		bottom: 0;
		height: 80rpx;
		background-color: #ffffff;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
		box-sizing: content-box;
	}

	.payment_button::after {
		content: '';
		display: block;
		clear: both;
	}

	.combined {
		font-size: 30rpx;
		text-align: center;
		line-height: 80rpx;
		width: 40%;
		background-color: #ffffff;
	}

	.combined_money {
		font-weight: bold;
		color: #5cc8b3;
	}

	.immediate {
		background: -webkit-linear-gradient(#77e2a4, #4ccdbc);
		color: #ffffff;
		line-height: 80rpx;
		font-size: 35rpx;
		width: 60%;
		text-align: center;
	}

	/* 弹出框 */
	.inputDialog {
		width: 600rpx;
		border-radius: 10rpx;
		background-color: #ffffff;
	}

	.inputDialog>.title {
		text-align: center;
		padding: 30rpx;
		font-size: 32rpx;
		line-height: 50rpx;
	}

	.button-bottom {
		display: flex;
		border-top: 1px solid #f0f0f0;
	}

	.button-bottom view {
		width: 50%;
		padding: 20rpx 0 20rpx 0;
		font-size: 32rpx;
		text-align: center;
	}

	.cancel {
		border-right: 1px solid #f0f0f0;
	}

	/* 绿色字体 */
	.green_words {
		color: #62c0ad;
	}

	.servicecard {
		padding: 0 30rpx 6rpx;
		margin: 20rpx 30rpx;
		background-color: #ffffff;
		border-radius: 10rpx;
	}

	.activeList {
		padding-bottom: 20rpx;
	}

	.couponCard {
		padding: 15rpx 30rpx;
		margin: 20rpx 30rpx;
		border-radius: 20rpx;
		background: linear-gradient(to right, #70c6fc, #fd4afd);
		// height: 200rpx;
	}

	.couponType {
		background: #4ccdbc;
		color: #ffffff;
		font-size: 12px;
		padding: 0 10rpx;
		border-radius: 10rpx;
		position: relative;
		top: -24rpx;
		left: -24rpx;
	}

	.disFlex {
		display: flex;
	}

	.danwei {
		color: red; // #4ccdbc;
		font-size: 54rpx;
	}

	.money {
		color: red; // #4ccdbc;
		font-size: 50rpx;
		display: inline-block;
		border-right: 1px dashed #cccccc;
		padding-right: 20rpx;
	}

	.manjian {
		font-size: 38rpx;
		color: red; // #4ccdbc;
		margin-left: 20rpx;
		margin-top: 20rpx;
	}

	.haveCount {
		margin: 10rpx auto 0;
		font-size: 12px;
		color: #ffffff; // #9c9b9b;
	}

	.zhushi {
		color: red; // #9c9b9b;
	}

	// .couponCard {
	//     width: 500rpx;
	//     display: inline-block;
	//     border-radius: 20rpx;
	//     border: 1px solid #4ccdbc;
	// }
	// .couponType {
	//     background: #4ccdbc;
	//     color: #ffffff;
	//     font-size: 12px;
	//     padding: 0 10rpx;
	//     border-radius: 10rpx;
	//     position: relative;
	//     top: -6rpx;
	//     left: -28rpx;
	// }
	// .disFlex {
	//     display: flex;
	// }
	// .danwei {
	//     color: #4ccdbc;
	//     font-size: 54rpx;
	//     font-weight: 900;
	// }
	// .money {
	//     color: #4ccdbc;
	//     font-size: 58rpx;
	//     font-weight: 900;
	//     display: inline-block;
	//     border-right: 1px dashed #cccccc;
	//     padding-right: 20rpx;
	// }
	// .manjian {
	//     font-size: 38rpx;
	//     color: #4ccdbc;
	//     // margin: 20px 20px 0;
	//     margin-left: 20rpx;
	//     margin-top: 20rpx;
	// }
	// .haveCount {
	//     margin: 10rpx auto 0;
	//     font-size: 12px;
	//     color: #9c9b9b;
	// }
</style>